<!doctype html>
<html lang="en" data-color-mode="dark">
<head>
<meta charset="utf-8">
<title>Glances 备忘清单
 &#x26;  glances cheatsheet &#x26;  Quick Reference</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta description="这是开始使用 Glances 系统监控工具的快速参考备忘单，可以帮助用户监视系统的各种性能指标

入门，为开发人员分享快速参考备忘单。">
<meta keywords="glances,reference,Quick,Reference,cheatsheet,cheat,sheet">
<link rel="icon" href="data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20height%3D%221em%22%20width%3D%221em%22%3E%20%3Cpath%20d%3D%22m21.66%2010.44-.98%204.18c-.84%203.61-2.5%205.07-5.62%204.77-.5-.04-1.04-.13-1.62-.27l-1.68-.4c-4.17-.99-5.46-3.05-4.48-7.23l.98-4.19c.2-.85.44-1.59.74-2.2%201.17-2.42%203.16-3.07%206.5-2.28l1.67.39c4.19.98%205.47%203.05%204.49%207.23Z%22%20fill%3D%22%23c9d1d9%22%2F%3E%20%3Cpath%20d%3D%22M15.06%2019.39c-.62.42-1.4.77-2.35%201.08l-1.58.52c-3.97%201.28-6.06.21-7.35-3.76L2.5%2013.28c-1.28-3.97-.22-6.07%203.75-7.35l1.58-.52c.41-.13.8-.24%201.17-.31-.3.61-.54%201.35-.74%202.2l-.98%204.19c-.98%204.18.31%206.24%204.48%207.23l1.68.4c.58.14%201.12.23%201.62.27Zm2.43-8.88c-.06%200-.12-.01-.19-.02l-4.85-1.23a.75.75%200%200%201%20.37-1.45l4.85%201.23a.748.748%200%200%201-.18%201.47Z%22%20fill%3D%22%23228e6c%22%20%2F%3E%20%3Cpath%20d%3D%22M14.56%2013.89c-.06%200-.12-.01-.19-.02l-2.91-.74a.75.75%200%200%201%20.37-1.45l2.91.74c.4.1.64.51.54.91-.08.34-.38.56-.72.56Z%22%20fill%3D%22%23228e6c%22%20%2F%3E%20%3C%2Fsvg%3E" type="image/svg+xml">
<link rel="stylesheet" href="../style/style.css">
<link rel="stylesheet" href="../style/katex.css">
</head>
<body><nav class="header-nav"><div class="max-container"><a href="../index.html" class="logo"><svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" height="1em" width="1em">
  <path d="m21.66 10.44-.98 4.18c-.84 3.61-2.5 5.07-5.62 4.77-.5-.04-1.04-.13-1.62-.27l-1.68-.4c-4.17-.99-5.46-3.05-4.48-7.23l.98-4.19c.2-.85.44-1.59.74-2.2 1.17-2.42 3.16-3.07 6.5-2.28l1.67.39c4.19.98 5.47 3.05 4.49 7.23Z" fill="#c9d1d9"></path>
  <path d="M15.06 19.39c-.62.42-1.4.77-2.35 1.08l-1.58.52c-3.97 1.28-6.06.21-7.35-3.76L2.5 13.28c-1.28-3.97-.22-6.07 3.75-7.35l1.58-.52c.41-.13.8-.24 1.17-.31-.3.61-.54 1.35-.74 2.2l-.98 4.19c-.98 4.18.31 6.24 4.48 7.23l1.68.4c.58.14 1.12.23 1.62.27Zm2.43-8.88c-.06 0-.12-.01-.19-.02l-4.85-1.23a.75.75 0 0 1 .37-1.45l4.85 1.23a.748.748 0 0 1-.18 1.47Z" fill="#228e6c"></path>
  <path d="M14.56 13.89c-.06 0-.12-.01-.19-.02l-2.91-.74a.75.75 0 0 1 .37-1.45l2.91.74c.4.1.64.51.54.91-.08.34-.38.56-.72.56Z" fill="#228e6c"></path>
</svg>
<span class="title">Quick Reference</span></a><div class="menu"><a href="javascript:void(0);" class="searchbtn" id="searchbtn"><svg xmlns="http://www.w3.org/2000/svg" height="1em" width="1em" viewBox="0 0 18 18">
  <path fill="currentColor" d="M17.71,16.29 L14.31,12.9 C15.4069846,11.5024547 16.0022094,9.77665502 16,8 C16,3.581722 12.418278,0 8,0 C3.581722,0 0,3.581722 0,8 C0,12.418278 3.581722,16 8,16 C9.77665502,16.0022094 11.5024547,15.4069846 12.9,14.31 L16.29,17.71 C16.4777666,17.8993127 16.7333625,18.0057983 17,18.0057983 C17.2666375,18.0057983 17.5222334,17.8993127 17.71,17.71 C17.8993127,17.5222334 18.0057983,17.2666375 18.0057983,17 C18.0057983,16.7333625 17.8993127,16.4777666 17.71,16.29 Z M2,8 C2,4.6862915 4.6862915,2 8,2 C11.3137085,2 14,4.6862915 14,8 C14,11.3137085 11.3137085,14 8,14 C4.6862915,14 2,11.3137085 2,8 Z"></path>
</svg><span>搜索</span><span>⌘K</span></a><a href="https://github.com/jaywcjlove/reference/blob/main/docs/glances.md" class="" target="__blank"><svg viewBox="0 0 36 36" fill="currentColor" height="1em" width="1em"><path d="m33 6.4-3.7-3.7a1.71 1.71 0 0 0-2.36 0L23.65 6H6a2 2 0 0 0-2 2v22a2 2 0 0 0 2 2h22a2 2 0 0 0 2-2V11.76l3-3a1.67 1.67 0 0 0 0-2.36ZM18.83 20.13l-4.19.93 1-4.15 9.55-9.57 3.23 3.23ZM29.5 9.43 26.27 6.2l1.85-1.85 3.23 3.23Z"></path><path fill="none" d="M0 0h36v36H0z"></path></svg><span>编辑</span></a><button id="darkMode" type="button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="light" height="1em" width="1em">
  <path d="M6.995 12c0 2.761 2.246 5.007 5.007 5.007s5.007-2.246 5.007-5.007-2.246-5.007-5.007-5.007S6.995 9.239 6.995 12zM11 19h2v3h-2zm0-17h2v3h-2zm-9 9h3v2H2zm17 0h3v2h-3zM5.637 19.778l-1.414-1.414 2.121-2.121 1.414 1.414zM16.242 6.344l2.122-2.122 1.414 1.414-2.122 2.122zM6.344 7.759 4.223 5.637l1.415-1.414 2.12 2.122zm13.434 10.605-1.414 1.414-2.122-2.122 1.414-1.414z"></path>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24" class="dark" height="1em" width="1em">
  <path d="M12 11.807A9.002 9.002 0 0 1 10.049 2a9.942 9.942 0 0 0-5.12 2.735c-3.905 3.905-3.905 10.237 0 14.142 3.906 3.906 10.237 3.905 14.143 0a9.946 9.946 0 0 0 2.735-5.119A9.003 9.003 0 0 1 12 11.807z"></path>
</svg>
</button><script src="../js/dark.js?v=1.5.5"></script><a href="https://github.com/jaywcjlove/reference" class="" target="__blank"><svg viewBox="0 0 16 16" fill="currentColor" height="1em" width="1em"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg></a></div></div></nav><div class="wrap h1body-exist max-container"><header class="wrap-header h1wrap"><h1 id="glances-备忘清单"><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em">
  <path d="M107.946667 838.4l57.173333 23.893333v-385.28l-103.68 250.026667c-17.493333 43.52 3.413333 93.44 46.506667 111.36z m832-157.866667L728.32 169.813333a85.888 85.888 0 0 0-77.226667-52.48c-11.093333 0-22.613333 1.706667-33.706666 6.4L302.933333 253.866667a85.290667 85.290667 0 0 0-46.08 110.933333l211.626667 510.72a85.248 85.248 0 0 0 110.933333 46.08l314.026667-130.133333a85.077333 85.077333 0 0 0 46.506667-110.933334zM336.213333 373.333333c-23.466667 0-42.666667-19.2-42.666666-42.666666s19.2-42.666667 42.666666-42.666667 42.666667 19.2 42.666667 42.666667-19.2 42.666667-42.666667 42.666666z m-85.333333 469.333334c0 46.933333 38.4 85.333333 85.333333 85.333333h61.866667l-147.2-355.84v270.506667z"></path>
</svg><a aria-hidden="true" tabindex="-1" href="#glances-备忘清单"><span class="icon icon-link"></span></a>Glances 备忘清单</h1><div class="wrap-body">
<p>这是开始使用 <a href="https://glances.readthedocs.io/en/latest/">Glances</a> 系统监控工具的快速参考备忘单，可以帮助用户监视系统的各种性能指标</p>
</div></header><div class="menu-tocs"><div class="menu-btn"><svg aria-hidden="true" fill="currentColor" height="1em" width="1em" viewBox="0 0 16 16" version="1.1" data-view-component="true">
  <path fill-rule="evenodd" d="M2 4a1 1 0 100-2 1 1 0 000 2zm3.75-1.5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zM3 8a1 1 0 11-2 0 1 1 0 012 0zm-1 6a1 1 0 100-2 1 1 0 000 2z"></path>
</svg></div><div class="menu-modal"><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#入门">入门</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#功能特点">功能特点</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#跨平台支持">跨平台支持</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#多种输出方式">多种输出方式</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#详细的系统监控">详细的系统监控</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#扩展功能">扩展功能</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#安装">安装</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#通过-pip-安装">通过 pip 安装</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#通过包管理器安装">通过包管理器安装</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#配置文件">配置文件</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#例子配置文件">例子配置文件</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#web-访问">Web 访问</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#使用方法">使用方法</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#启动命令行界面">启动命令行界面</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#启动-web-界面">启动 Web 界面</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#启动以特定模式输出">启动以特定模式输出</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#命令行选项">命令行选项</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#命令行选项-1">命令行选项</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#禁用启用选项">禁用启用选项</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#snmp">SNMP</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#命令行选项-2">命令行选项</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#命令行选项-3">命令行选项</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#命令行选项-4">命令行选项</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#命令行选项-5">命令行选项</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#命令行选项-6">命令行选项</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#键盘快捷键">键盘快捷键</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#快捷键">快捷键</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#快捷键-1">快捷键</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#快捷键-2">快捷键</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#配置">配置</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#位置">位置</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#语法">语法</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#cpu-插件的示例">CPU 插件的示例</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#influxdb-导出模块">InfluxDB 导出模块</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#nginx-amp">Nginx AMP</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#导出统计服务">导出统计服务</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#csv">CSV</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#json">JSON</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#cassandra">Cassandra</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#graph">Graph</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#couchdb">CouchDB</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#influxdb">InfluxDB</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#influxdb-最高版本-17x">InfluxDB （最高版本 1.7.x）</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#influxdb-v2来自-influxdb-v18xflux-和-influxdb-v2x">InfluxDB v2（来自 InfluxDB v1.8.x/Flux 和 InfluxDB v2.x）</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#elasticsearch">Elasticsearch</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#mqtt">MQTT</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#mongodb">MongoDB</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#opentsdb">OpenTSDB</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#kafka">Kafka</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#prometheus">Prometheus</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#rabbitmq">RabbitMQ</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#restful">RESTful</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#zeromq">ZeroMQ</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#riemann">Riemann</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#statsd">StatsD</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#另见">另见</a></div></div><div class="h1wrap-body"><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="入门"><a aria-hidden="true" tabindex="-1" href="#入门"><span class="icon icon-link"></span></a>入门</h2><div class="wrap-body">
</div></div><div class="h2wrap-body"><div class="wrap h3body-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="功能特点"><a aria-hidden="true" tabindex="-1" href="#功能特点"><span class="icon icon-link"></span></a>功能特点</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-2-->
<h4 id="跨平台支持"><a aria-hidden="true" tabindex="-1" href="#跨平台支持"><span class="icon icon-link"></span></a>跨平台支持</h4>
<ul>
<li><code>Glances</code> 支持多种操作系统，包括 Linux、Windows、macOS 和 FreeBSD。</li>
</ul>
<h4 id="多种输出方式"><a aria-hidden="true" tabindex="-1" href="#多种输出方式"><span class="icon icon-link"></span></a>多种输出方式</h4>
<ul>
<li><code>命令行界面（CLI）</code>：通过终端查看系统监控数据。</li>
<li><code>Web 界面</code>：通过浏览器访问并查看系统性能指标。</li>
<li><code>API 输出</code>：可以将数据通过 REST API 或者 MQTT 传输到其他系统或服务。</li>
</ul>
<h4 id="详细的系统监控"><a aria-hidden="true" tabindex="-1" href="#详细的系统监控"><span class="icon icon-link"></span></a>详细的系统监控</h4>
<ul>
<li><code>CPU</code>：实时显示 CPU 的使用率、每个核心的负载情况。</li>
<li><code>内存</code>：显示总内存、已用内存、缓存和交换分区的使用情况。</li>
<li><code>磁盘 I/O</code>：显示磁盘的读写速度和 I/O 操作数。</li>
<li><code>网络带宽</code>：显示网络接口的上传和下载速度。</li>
<li><code>文件系统</code>：显示各个挂载点的使用情况。</li>
<li><code>传感器</code>：显示系统温度、风扇速度等传感器数据（需要支持的硬件和驱动）。</li>
</ul>
<h4 id="扩展功能"><a aria-hidden="true" tabindex="-1" href="#扩展功能"><span class="icon icon-link"></span></a>扩展功能</h4>
<ul>
<li><code>插件系统</code>：支持通过插件扩展功能，可以自定义监控指标。</li>
<li><code>导出数据</code>：支持将监控数据导出为 CSV、JSON 等格式。</li>
<li><code>报警系统</code>：可以设置报警，当某些指标超过设定阈值时触发通知。</li>
</ul>
</div></div></div><div class="wrap h3body-exist"><div class="wrap-header h3wrap"><h3 id="安装"><a aria-hidden="true" tabindex="-1" href="#安装"><span class="icon icon-link"></span></a>安装</h3><div class="wrap-body">
<h4 id="通过-pip-安装"><a aria-hidden="true" tabindex="-1" href="#通过-pip-安装"><span class="icon icon-link"></span></a><strong>通过 pip 安装</strong></h4>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">pip <span class="token function">install</span> glances
</span></code></pre>
<h4 id="通过包管理器安装"><a aria-hidden="true" tabindex="-1" href="#通过包管理器安装"><span class="icon icon-link"></span></a><strong>通过包管理器安装</strong></h4>
<p><strong>Debian/Ubuntu</strong>:</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line"><span class="token function">sudo</span> <span class="token function">apt-get</span> <span class="token function">install</span> glances
</span></code></pre>
<p><strong>Fedora</strong>:</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line"><span class="token function">sudo</span> dnf <span class="token function">install</span> glances
</span></code></pre>
<p><strong>macOS (使用 Homebrew)</strong>:</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">brew <span class="token function">install</span> glances
</span></code></pre>
</div></div></div><div class="wrap h3body-exist"><div class="wrap-header h3wrap"><h3 id="配置文件"><a aria-hidden="true" tabindex="-1" href="#配置文件"><span class="icon icon-link"></span></a>配置文件</h3><div class="wrap-body">
<p>Glances 的配置文件位于 <code>~/.config/glances/glances.conf</code>。通过编辑这个文件，可以自定义 Glances 的显示和行为。</p>
<h4 id="例子配置文件"><a aria-hidden="true" tabindex="-1" href="#例子配置文件"><span class="icon icon-link"></span></a>例子配置文件</h4>
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">global</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">refresh</span><span class="token punctuation">=</span><span class="token value attr-value">2      # 设置刷新间隔（以秒为单位）</span>
</span><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">cpu</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">enable</span><span class="token punctuation">=</span><span class="token value attr-value">true    # 显示 CPU 负载平均值</span>
</span><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">mem</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">enable</span><span class="token punctuation">=</span><span class="token value attr-value">true    # 显示内存使用情况</span>
</span><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">disk</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">enable</span><span class="token punctuation">=</span><span class="token value attr-value">true    # 显示磁盘 I/O 信息</span>
</span><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">network</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">enable</span><span class="token punctuation">=</span><span class="token value attr-value">true    # 显示网络带宽使用情况</span>
</span></code></pre>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="web-访问"><a aria-hidden="true" tabindex="-1" href="#web-访问"><span class="icon icon-link"></span></a>Web 访问</h3><div class="wrap-body">
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line"><span class="token comment"># 使用 Glances 的 API：</span>
</span><span class="code-line">glances <span class="token parameter variable">-w</span>
</span><span class="code-line"><span class="token comment"># 访问 API：</span>
</span><span class="code-line"><span class="token function">curl</span> http://<span class="token operator">&#x3C;</span>your_ip<span class="token operator">></span>:61208/api/3/all
</span></code></pre>
<p><strong>使用 Docker 部署 Glances</strong>：</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line"><span class="token function">docker</span> run <span class="token parameter variable">--rm</span> <span class="token punctuation">\</span>
</span><span class="code-line">   <span class="token parameter variable">-v</span> /var/run/docker.sock:/var/run/docker.sock:ro <span class="token punctuation">\</span>
</span><span class="code-line">   <span class="token parameter variable">-v</span> /glances/conf:/glances/conf:ro <span class="token punctuation">\</span>
</span><span class="code-line">   <span class="token parameter variable">-v</span> /glances/data:/glances/data:rw <span class="token punctuation">\</span>
</span><span class="code-line">   <span class="token parameter variable">-p</span> <span class="token number">61208</span>-61209:61208-61209 <span class="token punctuation">\</span>
</span><span class="code-line">   <span class="token parameter variable">--name</span> glances nicolargo/glances
</span></code></pre>
</div></div></div><div class="wrap h3body-exist"><div class="wrap-header h3wrap"><h3 id="使用方法"><a aria-hidden="true" tabindex="-1" href="#使用方法"><span class="icon icon-link"></span></a>使用方法</h3><div class="wrap-body">
<h4 id="启动命令行界面"><a aria-hidden="true" tabindex="-1" href="#启动命令行界面"><span class="icon icon-link"></span></a><strong>启动命令行界面</strong></h4>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">glances
</span></code></pre>
<h4 id="启动-web-界面"><a aria-hidden="true" tabindex="-1" href="#启动-web-界面"><span class="icon icon-link"></span></a><strong>启动 Web 界面</strong></h4>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">glances <span class="token parameter variable">-w</span>
</span></code></pre>
<p>启动后，通过浏览器访问 <code>http://&#x3C;your_ip>:61208</code> 查看系统监控数据。</p>
<h4 id="启动以特定模式输出"><a aria-hidden="true" tabindex="-1" href="#启动以特定模式输出"><span class="icon icon-link"></span></a><strong>启动以特定模式输出</strong></h4>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">glances <span class="token parameter variable">--export</span> json  <span class="token comment"># JSON 输出</span>
</span><span class="code-line">glances <span class="token parameter variable">--export</span> csv   <span class="token comment"># CSV 输出</span>
</span></code></pre>
</div></div></div></div></div><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="命令行选项"><a aria-hidden="true" tabindex="-1" href="#命令行选项"><span class="icon icon-link"></span></a>命令行选项</h2><div class="wrap-body">
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="命令行选项-1"><a aria-hidden="true" tabindex="-1" href="#命令行选项-1"><span class="icon icon-link"></span></a>命令行选项</h3><div class="wrap-body">

































<table class="style-list"><thead><tr><th align="left">:-</th><th align="left">:-</th></tr></thead><tbody><tr><td align="left"><code>-h</code>, <code>--help</code></td><td align="left">显示此帮助信息并退出</td></tr><tr><td align="left"><code>-V</code>, <code>--version</code></td><td align="left">显示程序版本号并退出</td></tr><tr><td align="left"><code>-d</code>, <code>--debug</code></td><td align="left">启用调试模式</td></tr><tr><td align="left"><code>-C CONF_FILE</code>, <code>--config CONF_FILE</code></td><td align="left">配置文件的路径</td></tr><tr><td align="left"><code>--modules-list</code></td><td align="left">显示模块（插件和导出）列表并退出</td></tr><tr><td align="left"><code>--stdout PLUGINS_STATS</code></td><td align="left">显示插件统计信息到标准输出（用逗号分隔的插件/插件属性列表）</td></tr></tbody></table>
<!--rehype:className=style-list-->
</div></div></div><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="禁用启用选项"><a aria-hidden="true" tabindex="-1" href="#禁用启用选项"><span class="icon icon-link"></span></a>禁用启用选项</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-2-->

























































<table class="style-list"><thead><tr><th align="left">:-</th><th align="left">:-</th></tr></thead><tbody><tr><td align="left"><code>--disable-plugin PLUGIN</code></td><td align="left">禁用插件（用逗号分隔的列表）</td></tr><tr><td align="left"><code>--enable-plugin PLUGIN</code></td><td align="left">启用插件（用逗号分隔的列表）</td></tr><tr><td align="left"><code>--disable-process</code></td><td align="left">禁用进程模块（减少Glances的CPU消耗）</td></tr><tr><td align="left"><code>--disable-webui</code></td><td align="left">禁用Web界面（仅响应RESTful API）</td></tr><tr><td align="left"><code>--enable-history</code></td><td align="left">启用历史模式</td></tr><tr><td align="left"><code>--disable-bold</code></td><td align="left">禁用终端中的粗体模式</td></tr><tr><td align="left"><code>--disable-bg</code></td><td align="left">禁用终端中的背景颜色</td></tr><tr><td align="left"><code>--enable-process-extended</code></td><td align="left">启用顶级进程的扩展统计</td></tr><tr><td align="left"><code>--disable-check-update</code></td><td align="left">禁用在线Glances版本检查</td></tr><tr><td align="left"><code>--disable-autodiscover</code></td><td align="left">禁用自动发现功能</td></tr><tr><td align="left"><code>--light</code>, <code>--enable-light</code></td><td align="left">Curses UI的轻量模式（仅启用顶部菜单）</td></tr><tr><td align="left"><code>-q</code>, <code>--quiet</code></td><td align="left">不显示 curses 界面</td></tr></tbody></table>
<!--rehype:className=style-list-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="snmp"><a aria-hidden="true" tabindex="-1" href="#snmp"><span class="icon icon-link"></span></a>SNMP</h3><div class="wrap-body">

































<table class="style-list"><thead><tr><th align="left">:-</th><th align="left">:-</th></tr></thead><tbody><tr><td align="left"><code>--snmp-community SNMP_COMMUNITY</code></td><td align="left">SNMP社区</td></tr><tr><td align="left"><code>--snmp-port SNMP_PORT</code></td><td align="left">SNMP端口</td></tr><tr><td align="left"><code>--snmp-version SNMP_VERSION</code></td><td align="left">SNMP版本（1, 2c 或 3）</td></tr><tr><td align="left"><code>--snmp-user SNMP_USER</code></td><td align="left">SNMP用户名（仅适用于SNMPv3）</td></tr><tr><td align="left"><code>--snmp-auth SNMP_AUTH</code></td><td align="left">SNMP认证密钥（仅适用于SNMPv3）</td></tr><tr><td align="left"><code>--snmp-force</code></td><td align="left">强制SNMP模式</td></tr></tbody></table>
<!--rehype:className=style-list-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="命令行选项-2"><a aria-hidden="true" tabindex="-1" href="#命令行选项-2"><span class="icon icon-link"></span></a>命令行选项</h3><div class="wrap-body">





















<table class="style-list"><thead><tr><th align="left">:-</th><th align="left">:-</th></tr></thead><tbody><tr><td align="left"><code>--export EXPORT</code></td><td align="left">启用导出模块（用逗号分隔的列表）</td></tr><tr><td align="left"><code>--export-csv-file EXPORT_CSV_FILE</code></td><td align="left">CSV导出文件路径</td></tr><tr><td align="left"><code>--export-json-file EXPORT_JSON_FILE</code></td><td align="left">JSON导出文件路径</td></tr></tbody></table>
<!--rehype:className=style-list-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="命令行选项-3"><a aria-hidden="true" tabindex="-1" href="#命令行选项-3"><span class="icon icon-link"></span></a>命令行选项</h3><div class="wrap-body">





































<table class="style-list"><thead><tr><th align="left">:-</th><th align="left">:-</th></tr></thead><tbody><tr><td align="left"><code>-0</code>, <code>--disable-irix</code></td><td align="left">任务的CPU使用率将按CPU总数进行划分</td></tr><tr><td align="left"><code>-1</code>, <code>--percpu</code></td><td align="left">以每个CPU模式启动Glances</td></tr><tr><td align="left"><code>-2</code>, <code>--disable-left-sidebar</code></td><td align="left">禁用网络、磁盘I/O、文件系统和传感器模块</td></tr><tr><td align="left"><code>-3</code>, <code>--disable-quicklook</code></td><td align="left">禁用快速查看模块</td></tr><tr><td align="left"><code>-4</code>, <code>--full-quicklook</code></td><td align="left">仅启用快速查看和负载模块</td></tr><tr><td align="left"><code>-5</code>, <code>--disable-top</code></td><td align="left">禁用顶部菜单（快速查看、CPU、内存、交换区和负载）</td></tr><tr><td align="left"><code>-6</code>, <code>--meangpu</code></td><td align="left">以平均GPU模式启动Glances</td></tr></tbody></table>
<!--rehype:className=style-list-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="命令行选项-4"><a aria-hidden="true" tabindex="-1" href="#命令行选项-4"><span class="icon icon-link"></span></a>命令行选项</h3><div class="wrap-body">





































<table class="style-list"><thead><tr><th align="left">:-</th><th align="left">:-</th></tr></thead><tbody><tr><td align="left"><code>-c CLIENT</code>, <code>--client CLIENT</code></td><td align="left">通过IPv4/IPv6地址、主机名或主机名:端口连接到Glances服务器</td></tr><tr><td align="left"><code>-s</code>, <code>--server</code></td><td align="left">以服务器模式运行Glances</td></tr><tr><td align="left"><code>--browser</code></td><td align="left">启动客户端浏览器（服务器列表）</td></tr><tr><td align="left"><code>-p PORT</code>, <code>--port PORT</code></td><td align="left">定义客户端/服务器TCP端口 [默认：61209]</td></tr><tr><td align="left"><code>-B BIND_ADDRESS</code>, <code>--bind BIND_ADDRESS</code></td><td align="left">将服务器绑定到给定的IPv4/IPv6地址或主机名</td></tr><tr><td align="left"><code>--username</code></td><td align="left">定义客户端/服务器用户名</td></tr><tr><td align="left"><code>--password</code></td><td align="left">定义客户端/服务器密码</td></tr></tbody></table>
<!--rehype:className=style-list-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="命令行选项-5"><a aria-hidden="true" tabindex="-1" href="#命令行选项-5"><span class="icon icon-link"></span></a>命令行选项</h3><div class="wrap-body">





































<table class="style-list"><thead><tr><th align="left">:-</th><th align="left">:-</th></tr></thead><tbody><tr><td align="left"><code>-t TIME</code>, <code>--time TIME</code></td><td align="left">设置刷新时间（秒）[默认：3秒]</td></tr><tr><td align="left"><code>-w</code>, <code>--webserver</code></td><td align="left">以Web服务器模式运行Glances（需要bottle库）</td></tr><tr><td align="left"><code>--cached-time CACHED_TIME</code></td><td align="left">设置服务器缓存时间 [默认：1秒]</td></tr><tr><td align="left"><code>--open-web-browser</code></td><td align="left">尝试在默认的 Web 浏览器中打开Web界面</td></tr><tr><td align="left"><code>-f PROCESS_FILTER</code>, <code>--process-filter PROCESS_FILTER</code></td><td align="left">设置进程过滤模式（正则表达式）</td></tr><tr><td align="left"><code>--process-short-name</code></td><td align="left">强制使用进程名称的短名称</td></tr><tr><td align="left"><code>--hide-kernel-threads</code></td><td align="left">在进程列表中隐藏内核线程（Windows不可用）</td></tr></tbody></table>
<!--rehype:className=style-list-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="命令行选项-6"><a aria-hidden="true" tabindex="-1" href="#命令行选项-6"><span class="icon icon-link"></span></a>命令行选项</h3><div class="wrap-body">

































<table class="style-list"><thead><tr><th align="left">:-</th><th align="left">:-</th></tr></thead><tbody><tr><td align="left"><code>-b</code>, <code>--byte</code></td><td align="left">以每秒字节数显示网络速率</td></tr><tr><td align="left"><code>--diskio-show-ramfs</code></td><td align="left">在 DiskIO 插件中显示RAM文件系统</td></tr><tr><td align="left"><code>--diskio-iops</code></td><td align="left">在 DiskIO 插件中显示每秒I/O操作数</td></tr><tr><td align="left"><code>--fahrenheit</code></td><td align="left">以华氏度显示温度（默认是摄氏度）</td></tr><tr><td align="left"><code>--fs-free-space</code></td><td align="left">显示文件系统的可用空间而非已用空间</td></tr><tr><td align="left"><code>--theme-white</code></td><td align="left">优化显示颜色以适应白色背景</td></tr></tbody></table>
<!--rehype:className=style-list-->
</div></div></div></div></div><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="键盘快捷键"><a aria-hidden="true" tabindex="-1" href="#键盘快捷键"><span class="icon icon-link"></span></a>键盘快捷键</h2><div class="wrap-body">
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="快捷键"><a aria-hidden="true" tabindex="-1" href="#快捷键"><span class="icon icon-link"></span></a>快捷键</h3><div class="wrap-body">





























































































<table class="shortcuts left-align"><thead><tr><th>快捷键</th><th>功能</th></tr></thead><tbody><tr><td><code>ENTER</code></td><td>设置进程过滤器</td></tr><tr><td><code>a</code></td><td>自动排序进程列表</td></tr><tr><td><code>A</code></td><td>启用/禁用应用程序监控进程</td></tr><tr><td><code>b</code></td><td>在网络I/O中切换比特/秒或字节/秒</td></tr><tr><td><code>B</code></td><td>查看每秒磁盘I/O计数器</td></tr><tr><td><code>c</code></td><td>按CPU使用率排序进程</td></tr><tr><td><code>C</code></td><td>启用/禁用云统计</td></tr><tr><td><code>d</code></td><td>显示/隐藏磁盘I/O统计</td></tr><tr><td><code>D</code></td><td>启用/禁用Docker统计</td></tr><tr><td><code>e</code></td><td>启用/禁用顶级扩展统计</td></tr><tr><td><code>E</code></td><td>清除当前进程过滤器</td></tr><tr><td><code>f</code></td><td>显示/隐藏文件系统和文件夹监控统计</td></tr><tr><td><code>F</code></td><td>在文件系统使用和可用空间之间切换</td></tr><tr><td><code>g</code></td><td>为当前历史生成图表</td></tr><tr><td><code>G</code></td><td>启用/禁用GPU统计</td></tr><tr><td><code>h</code></td><td>显示/隐藏帮助屏幕</td></tr><tr><td><code>i</code></td><td>按I/O速率排序进程</td></tr><tr><td><code>I</code></td><td>显示/隐藏IP模块</td></tr><tr><td><code>+</code></td><td>增加选定进程的nice值/降低优先级(需要权限)- 仅在独立模式下</td></tr><tr><td><code>-</code></td><td>减少选定进程的nice值/提高优先级(需要权限)- 仅在独立模式下</td></tr><tr><td><code>k</code></td><td>终止选定进程(需要权限)- 仅在独立模式下</td></tr></tbody></table>
<!--rehype:className=shortcuts left-align-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="快捷键-1"><a aria-hidden="true" tabindex="-1" href="#快捷键-1"><span class="icon icon-link"></span></a>快捷键</h3><div class="wrap-body">

































































































<table class="shortcuts left-align"><thead><tr><th>快捷键</th><th>功能</th></tr></thead><tbody><tr><td><code>K</code></td><td>显示/隐藏TCP连接</td></tr><tr><td><code>l</code></td><td>显示/隐藏日志消息</td></tr><tr><td><code>m</code></td><td>按内存使用率排序进程</td></tr><tr><td><code>M</code></td><td>重置进程摘要的最小/最大值</td></tr><tr><td><code>n</code></td><td>显示/隐藏网络统计</td></tr><tr><td><code>N</code></td><td>显示/隐藏当前时间</td></tr><tr><td><code>p</code></td><td>按名称排序进程</td></tr><tr><td><code>P</code></td><td>启用/禁用端口统计</td></tr><tr><td><code>q|ESC|CTRL-C</code></td><td>退出当前Glances会话</td></tr><tr><td><code>Q</code></td><td>显示/隐藏IRQ模块</td></tr><tr><td><code>r</code></td><td>重置历史记录</td></tr><tr><td><code>R</code></td><td>显示/隐藏RAID插件</td></tr><tr><td><code>s</code></td><td>显示/隐藏传感器统计</td></tr><tr><td><code>S</code></td><td>启用/禁用微小曲线图</td></tr><tr><td><code>t</code></td><td>按CPU时间排序进程（TIME+）</td></tr><tr><td><code>T</code></td><td>以组合方式查看网络I/O</td></tr><tr><td><code>u</code></td><td>按用户排序进程</td></tr><tr><td><code>U</code></td><td>查看累积网络I/O</td></tr><tr><td><code>w</code></td><td>删除已完成的警告日志消息</td></tr><tr><td><code>W</code></td><td>显示/隐藏Wifi模块</td></tr><tr><td><code>x</code></td><td>删除已完成的警告和严重日志消息</td></tr><tr><td><code>z</code></td><td>显示/隐藏进程统计</td></tr></tbody></table>
<!--rehype:className=shortcuts left-align-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="快捷键-2"><a aria-hidden="true" tabindex="-1" href="#快捷键-2"><span class="icon icon-link"></span></a>快捷键</h3><div class="wrap-body">

















































































<table class="shortcuts left-align"><thead><tr><th>快捷键</th><th>功能</th></tr></thead><tbody><tr><td><code>0</code></td><td>启用/禁用Irix/Solaris模式。任务的CPU使用率将按CPU总数进行划分</td></tr><tr><td><code>1</code></td><td>在全局CPU和每个CPU统计之间切换</td></tr><tr><td><code>2</code></td><td>启用/禁用左侧边栏</td></tr><tr><td><code>3</code></td><td>启用/禁用快速查看模块</td></tr><tr><td><code>4</code></td><td>启用/禁用除快速查看和负载模块外的所有模块</td></tr><tr><td><code>5</code></td><td>启用/禁用顶部菜单（快速查看、CPU、内存、交换区和负载）</td></tr><tr><td><code>6</code></td><td>启用/禁用平均GPU模式</td></tr><tr><td><code>9</code></td><td>在黑白主题之间切换UI主题</td></tr><tr><td><code>/</code></td><td>在进程命令行或命令名称之间切换</td></tr><tr><td><code>F5</code></td><td>刷新curses用户界面的统计数据</td></tr><tr><td><code>LEFT</code></td><td>向左导航进程排序</td></tr><tr><td><code>RIGHT</code></td><td>向右导航进程排序</td></tr><tr><td><code>UP</code></td><td>在进程列表中向上</td></tr><tr><td><code>DOWN</code></td><td>在进程列表中向下。在Glances客户端浏览器中（通过<code>--browser</code>命令行参数访问）：</td></tr><tr><td><code>ENTER</code></td><td>运行选定的服务器</td></tr><tr><td><code>UP</code></td><td>在服务器列表中向上</td></tr><tr><td><code>DOWN</code></td><td>在服务器列表中向下</td></tr><tr><td><code>q|ESC</code></td><td>退出Glances</td></tr></tbody></table>
<!--rehype:className=shortcuts left-align-->
</div></div></div></div></div><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="配置"><a aria-hidden="true" tabindex="-1" href="#配置"><span class="icon icon-link"></span></a>配置</h2><div class="wrap-body">
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist col-span-2"><div class="wrap-header h3wrap"><h3 id="位置"><a aria-hidden="true" tabindex="-1" href="#位置"><span class="icon icon-link"></span></a>位置</h3><div class="wrap-body">
<!--rehype:wrap-class=col-span-2-->
<p>您可以将自己的 <code>glances.conf</code> 文件放在以下位置：</p>






























<table><thead><tr><th align="left">:--</th><th>--</th><th>--</th></tr></thead><tbody><tr><td align="left"><code>Linux</code>, <code>SunOS</code></td><td>~/.config/glances/, /etc/glances/, /usr/share/docs/glances/</td><td></td></tr><tr><td align="left"><code>*BSD</code></td><td>~/.config/glances/, /usr/local/etc/glances/, /usr/share/docs/glances/</td><td></td></tr><tr><td align="left"><code>macOS</code></td><td>~/Library/Application Support/glances/, /usr/local/etc/glances/, /usr/share/docs/glances/</td><td></td></tr><tr><td align="left"><code>Windows</code></td><td>%APPDATA%\glances\glances.conf</td><td></td></tr></tbody></table>
<hr>
<ul>
<li>在 Windows XP 上，%APPDATA% 为：<code>C:\Documents and Settings\&#x3C;USERNAME>\Application Data</code></li>
<li>在 Windows Vista 及更高版本上：<code>C:\Users\&#x3C;用户名>\AppData\Roaming</code></li>
</ul>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="语法"><a aria-hidden="true" tabindex="-1" href="#语法"><span class="icon icon-link"></span></a>语法</h3><div class="wrap-body">
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">global</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token comment"># 刷新率（默认为至少 2 秒）</span>
</span><span class="code-line"><span class="token comment"># 可以通过 -t &#x3C;sec> 选项覆盖</span>
</span><span class="code-line"><span class="token comment"># 也可以在每个插件部分覆盖它</span>
</span><span class="code-line"><span class="token key attr-name">refresh</span><span class="token punctuation">=</span><span class="token value attr-value">2</span>
</span><span class="code-line"><span class="token comment"># Glances 是否应该检查 PyPI 上是否有更新的版本？</span>
</span><span class="code-line"><span class="token key attr-name">check_update</span><span class="token punctuation">=</span><span class="token value attr-value">false</span>
</span><span class="code-line"><span class="token comment"># 历史大小（最大值数）</span>
</span><span class="code-line"><span class="token comment"># 默认值为28800：1天，每3秒1分</span>
</span><span class="code-line"><span class="token key attr-name">history_size</span><span class="token punctuation">=</span><span class="token value attr-value">28800</span>
</span></code></pre>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="cpu-插件的示例"><a aria-hidden="true" tabindex="-1" href="#cpu-插件的示例"><span class="icon icon-link"></span></a>CPU 插件的示例</h3><div class="wrap-body">
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">cpu</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">disable</span><span class="token punctuation">=</span><span class="token value attr-value">False</span>
</span><span class="code-line"><span class="token key attr-name">refresh</span><span class="token punctuation">=</span><span class="token value attr-value">3</span>
</span><span class="code-line"><span class="token key attr-name">user_careful</span><span class="token punctuation">=</span><span class="token value attr-value">50</span>
</span><span class="code-line"><span class="token key attr-name">user_warning</span><span class="token punctuation">=</span><span class="token value attr-value">70</span>
</span><span class="code-line"><span class="token key attr-name">user_critical</span><span class="token punctuation">=</span><span class="token value attr-value">90</span>
</span><span class="code-line"><span class="token key attr-name">iowait_careful</span><span class="token punctuation">=</span><span class="token value attr-value">50</span>
</span><span class="code-line"><span class="token key attr-name">iowait_warning</span><span class="token punctuation">=</span><span class="token value attr-value">70</span>
</span><span class="code-line"><span class="token key attr-name">iowait_critical</span><span class="token punctuation">=</span><span class="token value attr-value">90</span>
</span><span class="code-line"><span class="token key attr-name">system_careful</span><span class="token punctuation">=</span><span class="token value attr-value">50</span>
</span><span class="code-line"><span class="token key attr-name">system_warning</span><span class="token punctuation">=</span><span class="token value attr-value">70</span>
</span><span class="code-line"><span class="token key attr-name">system_critical</span><span class="token punctuation">=</span><span class="token value attr-value">90</span>
</span><span class="code-line"><span class="token key attr-name">steal_careful</span><span class="token punctuation">=</span><span class="token value attr-value">50</span>
</span><span class="code-line"><span class="token key attr-name">steal_warning</span><span class="token punctuation">=</span><span class="token value attr-value">70</span>
</span><span class="code-line"><span class="token key attr-name">steal_critical</span><span class="token punctuation">=</span><span class="token value attr-value">90</span>
</span></code></pre>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="influxdb-导出模块"><a aria-hidden="true" tabindex="-1" href="#influxdb-导出模块"><span class="icon icon-link"></span></a>InfluxDB 导出模块</h3><div class="wrap-body">
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">influxdb</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token comment"># 配置 --export influxdb 选项</span>
</span><span class="code-line"><span class="token comment"># https://influxdb.com/</span>
</span><span class="code-line"><span class="token key attr-name">host</span><span class="token punctuation">=</span><span class="token value attr-value">localhost</span>
</span><span class="code-line"><span class="token key attr-name">port</span><span class="token punctuation">=</span><span class="token value attr-value">8086</span>
</span><span class="code-line"><span class="token key attr-name">user</span><span class="token punctuation">=</span><span class="token value attr-value">root</span>
</span><span class="code-line"><span class="token key attr-name">password</span><span class="token punctuation">=</span><span class="token value attr-value">root</span>
</span><span class="code-line"><span class="token key attr-name">db</span><span class="token punctuation">=</span><span class="token value attr-value">glances</span>
</span><span class="code-line"><span class="token key attr-name">prefix</span><span class="token punctuation">=</span><span class="token value attr-value">localhost</span>
</span><span class="code-line"><span class="token comment">#tags=foo:bar,spam:eggs</span>
</span></code></pre>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="nginx-amp"><a aria-hidden="true" tabindex="-1" href="#nginx-amp"><span class="icon icon-link"></span></a>Nginx AMP</h3><div class="wrap-body">
<pre class="wrap-text"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">amp_nginx</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token comment"># 应启用 Nginx 状态页面 </span>
</span><span class="code-line"><span class="token comment"># https://easyengine.io/tutorials/nginx/status-page/</span>
</span><span class="code-line">
</span><span class="code-line"><span class="token key attr-name">enable</span><span class="token punctuation">=</span><span class="token value attr-value">true</span>
</span><span class="code-line"><span class="token key attr-name">regex</span><span class="token punctuation">=</span><span class="token value attr-value">\/usr\/sbin\/nginx</span>
</span><span class="code-line"><span class="token key attr-name">refresh</span><span class="token punctuation">=</span><span class="token value attr-value">60</span>
</span><span class="code-line"><span class="token key attr-name">one_line</span><span class="token punctuation">=</span><span class="token value attr-value">false</span>
</span><span class="code-line"><span class="token key attr-name">status_url</span><span class="token punctuation">=</span><span class="token value attr-value">http://localhost/nginx_status</span>
</span></code></pre>
<!--rehype:className=wrap-text-->
</div></div></div></div></div><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="导出统计服务"><a aria-hidden="true" tabindex="-1" href="#导出统计服务"><span class="icon icon-link"></span></a>导出统计服务</h2><div class="wrap-body">
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="csv"><a aria-hidden="true" tabindex="-1" href="#csv"><span class="icon icon-link"></span></a>CSV</h3><div class="wrap-body">
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">$ glances <span class="token parameter variable">--export</span> csv <span class="token punctuation">\</span>
</span><span class="code-line">   --export-csv-file /tmp/glances.csv <span class="token punctuation">\</span>
</span><span class="code-line">   <span class="token parameter variable">--quiet</span>
</span></code></pre>
<p>可以将统计数据导出到 CSV 文件</p>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="json"><a aria-hidden="true" tabindex="-1" href="#json"><span class="icon icon-link"></span></a>JSON</h3><div class="wrap-body">
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">$ glances <span class="token parameter variable">--export</span> json <span class="token punctuation">\</span>
</span><span class="code-line">   --export-json-file /tmp/glances.json
</span></code></pre>
<p>可以将统计信息导出到 JSON 文件</p>
</div></div></div><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="cassandra"><a aria-hidden="true" tabindex="-1" href="#cassandra"><span class="icon icon-link"></span></a>Cassandra</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-2-->
<p>您可以将统计数据导出到 Cassandra 或 Scylla 服务器</p>
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">cassandra</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">host</span><span class="token punctuation">=</span><span class="token value attr-value">localhost</span>
</span><span class="code-line"><span class="token key attr-name">port</span><span class="token punctuation">=</span><span class="token value attr-value">9042</span>
</span><span class="code-line"><span class="token key attr-name">protocol_version</span><span class="token punctuation">=</span><span class="token value attr-value">3</span>
</span><span class="code-line"><span class="token key attr-name">keyspace</span><span class="token punctuation">=</span><span class="token value attr-value">glances</span>
</span><span class="code-line"><span class="token key attr-name">replication_factor</span><span class="token punctuation">=</span><span class="token value attr-value">2</span>
</span><span class="code-line"><span class="token key attr-name">table</span><span class="token punctuation">=</span><span class="token value attr-value">localhost</span>
</span></code></pre>
<p>并运行 Glances：</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">$ glances <span class="token parameter variable">--export</span> cassandra
</span></code></pre>
<p>数据模型如下：</p>
<pre class="language-sql"><code class="language-sql code-highlight"><span class="code-line"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> <span class="token operator">&#x3C;</span><span class="token keyword">table</span><span class="token operator">></span> <span class="token punctuation">(</span>plugin <span class="token keyword">text</span><span class="token punctuation">,</span> <span class="token keyword">time</span> timeuuid<span class="token punctuation">,</span> stat map<span class="token operator">&#x3C;</span><span class="token keyword">text</span><span class="token punctuation">,</span><span class="token keyword">float</span><span class="token operator">></span><span class="token punctuation">,</span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span> <span class="token punctuation">(</span>plugin<span class="token punctuation">,</span> <span class="token keyword">time</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
</span></code></pre>
</div></div></div><div class="wrap h3body-not-exist col-span-2"><div class="wrap-header h3wrap"><h3 id="graph"><a aria-hidden="true" tabindex="-1" href="#graph"><span class="icon icon-link"></span></a>Graph</h3><div class="wrap-body">
<!--rehype:wrap-class=col-span-2-->
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">graph</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token comment"># --export graph 选项的配置</span>
</span><span class="code-line"><span class="token comment"># 设置创建图形（.svg 文件）的路径</span>
</span><span class="code-line"><span class="token comment"># 可以通过 --graph-path 命令行选项覆盖</span>
</span><span class="code-line"><span class="token key attr-name">path</span><span class="token punctuation">=</span><span class="token value attr-value">/tmp</span>
</span><span class="code-line"><span class="token comment"># 可以通过设置自动生成图表</span>
</span><span class="code-line"><span class="token comment"># generate_every 为一个非零值，对应于之间的秒数</span>
</span><span class="code-line"><span class="token comment"># 两代。将其设置为 0 以禁用图形自动生成。</span>
</span><span class="code-line"><span class="token key attr-name">generate_every</span><span class="token punctuation">=</span><span class="token value attr-value">60</span>
</span><span class="code-line"><span class="token comment"># 请参阅 Pygal lib 文档中的以下配置键定义</span>
</span><span class="code-line"><span class="token comment"># http://pygal.org/en/stable/documentation/index.html</span>
</span><span class="code-line"><span class="token key attr-name">width</span><span class="token punctuation">=</span><span class="token value attr-value">800</span>
</span><span class="code-line"><span class="token key attr-name">height</span><span class="token punctuation">=</span><span class="token value attr-value">600</span>
</span><span class="code-line"><span class="token key attr-name">style</span><span class="token punctuation">=</span><span class="token value attr-value">DarkStyle</span>
</span></code></pre>
<p>并运行 Glances：</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">$ glances <span class="token parameter variable">--export</span> graph <span class="token punctuation">\</span>
</span><span class="code-line">      --export-graph-path /tmp
</span></code></pre>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="couchdb"><a aria-hidden="true" tabindex="-1" href="#couchdb"><span class="icon icon-link"></span></a>CouchDB</h3><div class="wrap-body">
<p>您可以将统计数据导出到 CouchDB 服务器</p>
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">mongodb</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">host</span><span class="token punctuation">=</span><span class="token value attr-value">localhost</span>
</span><span class="code-line"><span class="token key attr-name">port</span><span class="token punctuation">=</span><span class="token value attr-value">27017</span>
</span><span class="code-line"><span class="token key attr-name">db</span><span class="token punctuation">=</span><span class="token value attr-value">glances</span>
</span><span class="code-line"><span class="token key attr-name">user</span><span class="token punctuation">=</span><span class="token value attr-value">root</span>
</span><span class="code-line"><span class="token key attr-name">password</span><span class="token punctuation">=</span><span class="token value attr-value">example</span>
</span></code></pre>
<p>并运行 Glances：</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">$ glances <span class="token parameter variable">--export</span> mongodb
</span></code></pre>
</div></div></div><div class="wrap h3body-exist col-span-2 row-span-4"><div class="wrap-header h3wrap"><h3 id="influxdb"><a aria-hidden="true" tabindex="-1" href="#influxdb"><span class="icon icon-link"></span></a>InfluxDB</h3><div class="wrap-body">
<!--rehype:wrap-class=col-span-2 row-span-4-->
<p>您可以将统计数据导出到 InfluxDB 服务器（时间序列服务器）</p>



































<table class="show-header"><thead><tr><th align="left">测量</th><th>字段</th><th>标签</th></tr></thead><tbody><tr><td align="left">cpu</td><td>user system iowait…</td><td>hostname</td></tr><tr><td align="left">network</td><td>read_bytes write_bytes time_since_update…</td><td>hostname disk_name</td></tr><tr><td align="left">diskio</td><td>rx tx time_since_update…</td><td>hostname interface_name</td></tr><tr><td align="left">docker</td><td>cpu_percent memory_usage…</td><td>hostname name</td></tr><tr><td align="left">gpu</td><td>proc mem temperature…</td><td>hostname gpu_id</td></tr></tbody></table>
<!--rehype:className=show-header-->
<h4 id="influxdb-最高版本-17x"><a aria-hidden="true" tabindex="-1" href="#influxdb-最高版本-17x"><span class="icon icon-link"></span></a>InfluxDB （最高版本 1.7.x）</h4>
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">influxdb</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">host</span><span class="token punctuation">=</span><span class="token value attr-value">localhost</span>
</span><span class="code-line"><span class="token key attr-name">port</span><span class="token punctuation">=</span><span class="token value attr-value">8086</span>
</span><span class="code-line"><span class="token key attr-name">protocol</span><span class="token punctuation">=</span><span class="token value attr-value">http</span>
</span><span class="code-line"><span class="token key attr-name">user</span><span class="token punctuation">=</span><span class="token value attr-value">root</span>
</span><span class="code-line"><span class="token key attr-name">password</span><span class="token punctuation">=</span><span class="token value attr-value">root</span>
</span><span class="code-line"><span class="token key attr-name">db</span><span class="token punctuation">=</span><span class="token value attr-value">glances</span>
</span><span class="code-line"><span class="token comment"># 所有测量名称都会添加前缀</span>
</span><span class="code-line"><span class="token comment"># Ex: prefix=foo</span>
</span><span class="code-line"><span class="token comment">#     => foo.cpu</span>
</span><span class="code-line"><span class="token comment">#     => foo.mem</span>
</span><span class="code-line"><span class="token comment"># 您还可以使用动态值</span>
</span><span class="code-line"><span class="token comment">#prefix=foo</span>
</span><span class="code-line"><span class="token comment"># 将为所有测量添加以下标签</span>
</span><span class="code-line"><span class="token comment"># 您还可以使用动态值</span>
</span><span class="code-line"><span class="token comment"># 注意：主机名始终作为标签添加</span>
</span><span class="code-line"><span class="token comment">#tags=foo:bar,spam:eggs,domain:`domainname`</span>
</span></code></pre>
<p>并运行 Glances：</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">$ glances <span class="token parameter variable">--export</span> influxdb
</span></code></pre>
<h4 id="influxdb-v2来自-influxdb-v18xflux-和-influxdb-v2x"><a aria-hidden="true" tabindex="-1" href="#influxdb-v2来自-influxdb-v18xflux-和-influxdb-v2x"><span class="icon icon-link"></span></a>InfluxDB v2（来自 InfluxDB v1.8.x/Flux 和 InfluxDB v2.x）</h4>
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">influxdb2</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">host</span><span class="token punctuation">=</span><span class="token value attr-value">localhost</span>
</span><span class="code-line"><span class="token key attr-name">port</span><span class="token punctuation">=</span><span class="token value attr-value">8086</span>
</span><span class="code-line"><span class="token key attr-name">protocol</span><span class="token punctuation">=</span><span class="token value attr-value">http</span>
</span><span class="code-line"><span class="token key attr-name">org</span><span class="token punctuation">=</span><span class="token value attr-value">nicolargo</span>
</span><span class="code-line"><span class="token key attr-name">bucket</span><span class="token punctuation">=</span><span class="token value attr-value">glances</span>
</span><span class="code-line"><span class="token key attr-name">token</span><span class="token punctuation">=</span><span class="token value attr-value">EjFUTWe8U-MIseEAkaVIgVnej_TrUpDy==</span>
</span><span class="code-line"><span class="token comment"># 设置两个导出之间的间隔（以秒为单位）</span>
</span><span class="code-line"><span class="token comment"># 如果时间间隔设置为 0，</span>
</span><span class="code-line"><span class="token comment"># 则使用 Glances 刷新时间（默认行为）</span>
</span><span class="code-line"><span class="token comment">#interval=0</span>
</span><span class="code-line"><span class="token comment"># 将为所有测量名称添加前缀</span>
</span><span class="code-line"><span class="token comment"># Ex: prefix=foo</span>
</span><span class="code-line"><span class="token comment">#     => foo.cpu</span>
</span><span class="code-line"><span class="token comment">#     => foo.mem</span>
</span><span class="code-line"><span class="token comment"># 您还可以使用动态值</span>
</span><span class="code-line"><span class="token comment">#prefix=foo</span>
</span><span class="code-line"><span class="token comment"># 将为所有测量添加以下标签</span>
</span><span class="code-line"><span class="token comment"># 您还可以使用动态值.</span>
</span><span class="code-line"><span class="token comment"># 注意：主机名始终作为标签添加</span>
</span><span class="code-line"><span class="token comment">#tags=foo:bar,spam:eggs,domain:`domainname`</span>
</span></code></pre>
<p>并运行 Glances：</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">$ glances <span class="token parameter variable">--export</span> influxdb2
</span></code></pre>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="elasticsearch"><a aria-hidden="true" tabindex="-1" href="#elasticsearch"><span class="icon icon-link"></span></a>Elasticsearch</h3><div class="wrap-body">
<p>可以将统计数据导出到 Elasticsearch 服务器</p>
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">elasticsearch</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">host</span><span class="token punctuation">=</span><span class="token value attr-value">localhost</span>
</span><span class="code-line"><span class="token key attr-name">port</span><span class="token punctuation">=</span><span class="token value attr-value">9200</span>
</span><span class="code-line"><span class="token key attr-name">index</span><span class="token punctuation">=</span><span class="token value attr-value">glances</span>
</span></code></pre>
<p>并运行 Glances：</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">$ glances <span class="token parameter variable">--export</span> elasticsearch
</span></code></pre>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="mqtt"><a aria-hidden="true" tabindex="-1" href="#mqtt"><span class="icon icon-link"></span></a>MQTT</h3><div class="wrap-body">
<p>您可以将统计信息导出到 <code>MQTT</code> 服务器</p>
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">mqtt</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">host</span><span class="token punctuation">=</span><span class="token value attr-value">localhost</span>
</span><span class="code-line"><span class="token key attr-name">port</span><span class="token punctuation">=</span><span class="token value attr-value">883</span>
</span><span class="code-line"><span class="token key attr-name">tls</span><span class="token punctuation">=</span><span class="token value attr-value">true</span>
</span><span class="code-line"><span class="token key attr-name">user</span><span class="token punctuation">=</span><span class="token value attr-value">glances</span>
</span><span class="code-line"><span class="token key attr-name">password</span><span class="token punctuation">=</span><span class="token value attr-value">glances</span>
</span><span class="code-line"><span class="token key attr-name">topic</span><span class="token punctuation">=</span><span class="token value attr-value">glances</span>
</span><span class="code-line"><span class="token key attr-name">topic_structure</span><span class="token punctuation">=</span><span class="token value attr-value">per-metric</span>
</span></code></pre>
<p>并运行 Glances：</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">$ glances <span class="token parameter variable">--export</span> mqtt
</span></code></pre>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="mongodb"><a aria-hidden="true" tabindex="-1" href="#mongodb"><span class="icon icon-link"></span></a>MongoDB</h3><div class="wrap-body">
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">couchdb</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">host</span><span class="token punctuation">=</span><span class="token value attr-value">localhost</span>
</span><span class="code-line"><span class="token key attr-name">port</span><span class="token punctuation">=</span>
</span><span class="code-line"><span class="token key attr-name">user</span><span class="token punctuation">=</span><span class="token value attr-value">root</span>
</span><span class="code-line"><span class="token key attr-name">password</span><span class="token punctuation">=</span><span class="token value attr-value">example</span>
</span><span class="code-line"><span class="token key attr-name">db</span><span class="token punctuation">=</span><span class="token value attr-value">glances</span>
</span></code></pre>
<p>并运行 Glances：</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">$ glances <span class="token parameter variable">--export</span> couchdb
</span></code></pre>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="opentsdb"><a aria-hidden="true" tabindex="-1" href="#opentsdb"><span class="icon icon-link"></span></a>OpenTSDB</h3><div class="wrap-body">
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">opentsdb</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">host</span><span class="token punctuation">=</span><span class="token value attr-value">localhost</span>
</span><span class="code-line"><span class="token key attr-name">port</span><span class="token punctuation">=</span><span class="token value attr-value">4242</span>
</span><span class="code-line"><span class="token key attr-name">prefix</span><span class="token punctuation">=</span><span class="token value attr-value">glances</span>
</span><span class="code-line"><span class="token key attr-name">tags</span><span class="token punctuation">=</span><span class="token value attr-value">foo:bar,spam:eggs</span>
</span></code></pre>
<p>并运行 Glances：</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">$ glances <span class="token parameter variable">--export</span> opentsdb
</span></code></pre>
</div></div></div><div class="wrap h3body-not-exist col-span-2 row-span-3"><div class="wrap-header h3wrap"><h3 id="kafka"><a aria-hidden="true" tabindex="-1" href="#kafka"><span class="icon icon-link"></span></a>Kafka</h3><div class="wrap-body">
<!--rehype:wrap-class=col-span-2 row-span-3-->
<p>您可以将统计信息导出到 Kafka 服务器</p>
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">kafka</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">host</span><span class="token punctuation">=</span><span class="token value attr-value">localhost</span>
</span><span class="code-line"><span class="token key attr-name">port</span><span class="token punctuation">=</span><span class="token value attr-value">9092</span>
</span><span class="code-line"><span class="token key attr-name">topic</span><span class="token punctuation">=</span><span class="token value attr-value">glances</span>
</span><span class="code-line"><span class="token comment">#compression=gzip</span>
</span><span class="code-line"><span class="token comment"># Tags will be added for all events</span>
</span><span class="code-line"><span class="token comment">#tags=foo:bar,spam:eggs</span>
</span><span class="code-line"><span class="token comment"># You can also use dynamic values</span>
</span><span class="code-line"><span class="token comment">#tags=hostname:`hostname -f`</span>
</span></code></pre>
<p>并运行 Glances：</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">$ glances <span class="token parameter variable">--export</span> kafka
</span></code></pre>
<p>内存插件的记录示例：</p>
<pre class="wrap-text"><code class="language-py code-highlight"><span class="code-line">ConsumerRecord<span class="token punctuation">(</span>topic<span class="token operator">=</span><span class="token string">u'glances'</span><span class="token punctuation">,</span> partition<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">,</span> offset<span class="token operator">=</span><span class="token number">1305</span><span class="token punctuation">,</span> timestamp<span class="token operator">=</span><span class="token number">1490460592248</span><span class="token punctuation">,</span> timestamp_type<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">,</span> key<span class="token operator">=</span><span class="token string">'mem'</span><span class="token punctuation">,</span> value<span class="token operator">=</span><span class="token string">u'{"available": 2094710784, "used": 5777428480, "cached": 2513543168, "mem_careful": 50.0, "percent": 73.4, "free": 2094710784, "mem_critical": 90.0, "inactive": 2361626624, "shared": 475504640, "history_size": 28800.0, "mem_warning": 70.0, "total": 7872139264, "active": 4834361344, "buffers": 160112640}'</span><span class="token punctuation">,</span> checksum<span class="token operator">=</span><span class="token number">214895201</span><span class="token punctuation">,</span> serialized_key_size<span class="token operator">=</span><span class="token number">3</span><span class="token punctuation">,</span> serialized_value_size<span class="token operator">=</span><span class="token number">303</span><span class="token punctuation">)</span>
</span></code></pre>
<!--rehype:className=wrap-text-->
<p>使用 Kafka Glances 插件的 Python 代码示例：</p>
<pre class="language-py"><code class="language-py code-highlight"><span class="code-line"><span class="token keyword">from</span> kafka <span class="token keyword">import</span> KafkaConsumer
</span><span class="code-line"><span class="token keyword">import</span> json
</span><span class="code-line">
</span><span class="code-line">consumer <span class="token operator">=</span> KafkaConsumer<span class="token punctuation">(</span><span class="token string">'glances'</span><span class="token punctuation">,</span> value_deserializer<span class="token operator">=</span>json<span class="token punctuation">.</span>loads<span class="token punctuation">)</span>
</span><span class="code-line"><span class="token keyword">for</span> s <span class="token keyword">in</span> consumer<span class="token punctuation">:</span>
</span><span class="code-line">  <span class="token keyword">print</span><span class="token punctuation">(</span>s<span class="token punctuation">)</span>
</span></code></pre>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="prometheus"><a aria-hidden="true" tabindex="-1" href="#prometheus"><span class="icon icon-link"></span></a>Prometheus</h3><div class="wrap-body">
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">prometheus</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">host</span><span class="token punctuation">=</span><span class="token value attr-value">localhost</span>
</span><span class="code-line"><span class="token key attr-name">port</span><span class="token punctuation">=</span><span class="token value attr-value">9091</span>
</span><span class="code-line"><span class="token key attr-name">prefix</span><span class="token punctuation">=</span><span class="token value attr-value">glances</span>
</span><span class="code-line"><span class="token key attr-name">labels</span><span class="token punctuation">=</span><span class="token value attr-value">src:glances</span>
</span></code></pre>
<p>并运行 Glances：</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">$ glances <span class="token parameter variable">--export</span> prometheus
</span></code></pre>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="rabbitmq"><a aria-hidden="true" tabindex="-1" href="#rabbitmq"><span class="icon icon-link"></span></a>RabbitMQ</h3><div class="wrap-body">
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">rabbitmq</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">host</span><span class="token punctuation">=</span><span class="token value attr-value">localhost</span>
</span><span class="code-line"><span class="token key attr-name">port</span><span class="token punctuation">=</span><span class="token value attr-value">5672</span>
</span><span class="code-line"><span class="token key attr-name">user</span><span class="token punctuation">=</span><span class="token value attr-value">glances</span>
</span><span class="code-line"><span class="token key attr-name">password</span><span class="token punctuation">=</span><span class="token value attr-value">glances</span>
</span><span class="code-line"><span class="token key attr-name">queue</span><span class="token punctuation">=</span><span class="token value attr-value">glances_queue</span>
</span><span class="code-line"><span class="token comment">#protocol=amqps</span>
</span></code></pre>
<p>并运行 Glances：</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">$ glances <span class="token parameter variable">--export</span> rabbitmq
</span></code></pre>
</div></div></div><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="restful"><a aria-hidden="true" tabindex="-1" href="#restful"><span class="icon icon-link"></span></a>RESTful</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-2-->
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">restful</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token comment"># --export-restful 选项的配置</span>
</span><span class="code-line"><span class="token comment"># 例如，导出到 http://localhost:6789/</span>
</span><span class="code-line"><span class="token key attr-name">host</span><span class="token punctuation">=</span><span class="token value attr-value">localhost</span>
</span><span class="code-line"><span class="token key attr-name">port</span><span class="token punctuation">=</span><span class="token value attr-value">6789</span>
</span><span class="code-line"><span class="token key attr-name">protocol</span><span class="token punctuation">=</span><span class="token value attr-value">http</span>
</span><span class="code-line"><span class="token key attr-name">path</span><span class="token punctuation">=</span><span class="token value attr-value">/</span>
</span></code></pre>
<p>URL语法</p>
<pre><code class="code-highlight"><span class="code-line">http://localhost:6789/
</span><span class="code-line">|      |         |   |
</span><span class="code-line">|      |         |   path
</span><span class="code-line">|      |         port
</span><span class="code-line">|      host
</span><span class="code-line">protocol
</span></code></pre>
<p>并运行 Glances</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">$ glances <span class="token parameter variable">--export</span> restful
</span></code></pre>
</div></div></div><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="zeromq"><a aria-hidden="true" tabindex="-1" href="#zeromq"><span class="icon icon-link"></span></a>ZeroMQ</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-2-->
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">zeromq</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">host</span><span class="token punctuation">=</span><span class="token value attr-value">127.0.0.1</span>
</span><span class="code-line"><span class="token key attr-name">port</span><span class="token punctuation">=</span><span class="token value attr-value">5678</span>
</span><span class="code-line"><span class="token key attr-name">prefix</span><span class="token punctuation">=</span><span class="token value attr-value">G</span>
</span></code></pre>
<p>并运行 Glances</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">$ glances <span class="token parameter variable">--export</span> zeromq
</span></code></pre>
<p>以下是订阅 Glances 统计数据的简单 Python 客户端：</p>
<pre class="language-py"><code class="language-py code-highlight"><span class="code-line"><span class="token keyword">import</span> json
</span><span class="code-line"><span class="token keyword">import</span> zmq
</span><span class="code-line">
</span><span class="code-line">context <span class="token operator">=</span> zmq<span class="token punctuation">.</span>Context<span class="token punctuation">(</span><span class="token punctuation">)</span>
</span><span class="code-line">
</span><span class="code-line">subscriber <span class="token operator">=</span> context<span class="token punctuation">.</span>socket<span class="token punctuation">(</span>zmq<span class="token punctuation">.</span>SUB<span class="token punctuation">)</span>
</span><span class="code-line">subscriber<span class="token punctuation">.</span>setsockopt<span class="token punctuation">(</span>zmq<span class="token punctuation">.</span>SUBSCRIBE<span class="token punctuation">,</span> <span class="token string">'G'</span><span class="token punctuation">)</span>
</span><span class="code-line">subscriber<span class="token punctuation">.</span>connect<span class="token punctuation">(</span><span class="token string">"tcp://127.0.0.1:5678"</span><span class="token punctuation">)</span>
</span><span class="code-line">
</span><span class="code-line"><span class="token keyword">while</span> <span class="token boolean">True</span><span class="token punctuation">:</span>
</span><span class="code-line">    _<span class="token punctuation">,</span> plugin<span class="token punctuation">,</span> data_raw <span class="token operator">=</span> subscriber<span class="token punctuation">.</span>recv_multipart<span class="token punctuation">(</span><span class="token punctuation">)</span>
</span><span class="code-line">    data <span class="token operator">=</span> json<span class="token punctuation">.</span>loads<span class="token punctuation">(</span>data_raw<span class="token punctuation">)</span>
</span><span class="code-line">    <span class="token keyword">print</span><span class="token punctuation">(</span><span class="token string">'{} => {}'</span><span class="token punctuation">.</span><span class="token builtin">format</span><span class="token punctuation">(</span>plugin<span class="token punctuation">,</span> data<span class="token punctuation">)</span><span class="token punctuation">)</span>
</span><span class="code-line">
</span><span class="code-line">subscriber<span class="token punctuation">.</span>close<span class="token punctuation">(</span><span class="token punctuation">)</span>
</span><span class="code-line">context<span class="token punctuation">.</span>term<span class="token punctuation">(</span><span class="token punctuation">)</span>
</span></code></pre>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="riemann"><a aria-hidden="true" tabindex="-1" href="#riemann"><span class="icon icon-link"></span></a>Riemann</h3><div class="wrap-body">
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">riemann</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">host</span><span class="token punctuation">=</span><span class="token value attr-value">localhost</span>
</span><span class="code-line"><span class="token key attr-name">port</span><span class="token punctuation">=</span><span class="token value attr-value">5555</span>
</span></code></pre>
<p>并运行 Glances</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">$ glances <span class="token parameter variable">--export</span> riemann
</span></code></pre>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="statsd"><a aria-hidden="true" tabindex="-1" href="#statsd"><span class="icon icon-link"></span></a>StatsD</h3><div class="wrap-body">
<pre class="language-ini"><code class="language-ini code-highlight"><span class="code-line"><span class="token section"><span class="token punctuation">[</span><span class="token section-name selector">statsd</span><span class="token punctuation">]</span></span>
</span><span class="code-line"><span class="token key attr-name">host</span><span class="token punctuation">=</span><span class="token value attr-value">localhost</span>
</span><span class="code-line"><span class="token key attr-name">port</span><span class="token punctuation">=</span><span class="token value attr-value">8125</span>
</span><span class="code-line"><span class="token key attr-name">prefix</span><span class="token punctuation">=</span><span class="token value attr-value">glances</span>
</span></code></pre>
<p>并运行 Glances</p>
<pre class="language-sh"><code class="language-sh code-highlight"><span class="code-line">$ glances <span class="token parameter variable">--export</span> statsd
</span></code></pre>
</div></div></div></div></div><div class="wrap h2body-not-exist"><div class="wrap-header h2wrap"><h2 id="另见"><a aria-hidden="true" tabindex="-1" href="#另见"><span class="icon icon-link"></span></a>另见</h2><div class="wrap-body">
<ul>
<li><a href="https://nicolargo.github.io/glances/">Glances 官方文档</a> <em>nicolargo.github.io</em></li>
</ul>
</div></div><div class="h2wrap-body"></div></div></div><script src="https://giscus.app/client.js" data-repo="jaywcjlove/reference" data-repo-id="R_kgDOID2-Mw" data-category="Q&#x26;A" data-category-id="DIC_kwDOID2-M84CS5wo" data-mapping="pathname" data-strict="0" data-reactions-enabled="1" data-emit-metadata="0" data-input-position="bottom" data-theme="dark" data-lang="zh-CN" crossorigin="anonymous" async></script><div class="giscus"></div></div><footer class="footer-wrap"><footer class="max-container">© 2022 <a href="https://wangchujiang.com/#/app" target="_blank">Kenny Wang</a>.</footer></footer><script src="../data.js?v=1.5.5" defer></script><script src="../js/fuse.min.js?v=1.5.5" defer></script><script src="../js/main.js?v=1.5.5" defer></script><div id="mysearch"><div class="mysearch-box"><div class="mysearch-input"><div><svg xmlns="http://www.w3.org/2000/svg" height="1em" width="1em" viewBox="0 0 18 18">
  <path fill="currentColor" d="M17.71,16.29 L14.31,12.9 C15.4069846,11.5024547 16.0022094,9.77665502 16,8 C16,3.581722 12.418278,0 8,0 C3.581722,0 0,3.581722 0,8 C0,12.418278 3.581722,16 8,16 C9.77665502,16.0022094 11.5024547,15.4069846 12.9,14.31 L16.29,17.71 C16.4777666,17.8993127 16.7333625,18.0057983 17,18.0057983 C17.2666375,18.0057983 17.5222334,17.8993127 17.71,17.71 C17.8993127,17.5222334 18.0057983,17.2666375 18.0057983,17 C18.0057983,16.7333625 17.8993127,16.4777666 17.71,16.29 Z M2,8 C2,4.6862915 4.6862915,2 8,2 C11.3137085,2 14,4.6862915 14,8 C14,11.3137085 11.3137085,14 8,14 C4.6862915,14 2,11.3137085 2,8 Z"></path>
</svg><input id="mysearch-input" type="search" placeholder="搜索" autocomplete="off"><div class="mysearch-clear"></div></div><button id="mysearch-close" type="button">搜索</button></div><div class="mysearch-result"><div id="mysearch-menu"></div><div id="mysearch-content"></div></div></div></div></body>
</html>
